package com.shujia.flink.source;

import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;

public class Demo02SocketSource {
    public static void main(String[] args) throws Exception {
        // 从Socket套接字构建DS：无界流，数据源源不断，程序会一直运行
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStreamSource<String> socketDS = env.socketTextStream("master",8888);

        socketDS.keyBy(w->w, Types.STRING).print();

        env.execute();
    }
}
